//长按扫描按钮
var oDiv = document.getElementById('div1');
function touches(ev) {
	if (ev.touches.length == 1) {
		switch (ev.type) {
			case 'touchstart':
				$(".finger_line").show();
				$(".Start-zhiwen-info").show();
				$(".finger_line").animate({
					'bottom': '85px'
				}, 1000, function() {
					$(".Start-zhiwen-info").html("扫描完成");
					$(".Start").fadeOut(100, function() {
						$(".bodyBlock").css("opacity", "1");
					});
				});
				break;
		}
	}
}
oDiv.addEventListener('touchstart', touches, false);

/*页面加载完成之后*/
window.onload = function() {
	$("#loading").hide();
	//	$(".Start").css("opacity","1");
	$(".Start").css("display", "none");
	$(".bodyBlock").css("opacity", "1");
	$("body").css("background", "#000");

	bodyHeight = $(window).height();
	$(".bodyBlock").height(bodyHeight);
	$(".bodyBlock,.swiper-container,.swiper-slide").height(bodyHeight);

	var slideWidth = $(".bodyBlock").width();
	var slideHeight = $(".bodyBlock").height();
	scaleW = slideWidth / 320;
	scaleH = slideHeight / 480;
	var resizes = document.querySelectorAll('.resize');
	for (var j = 0; j < resizes.length; j++) {
		resizes[j].style.width = parseInt(resizes[j].style.width) * scaleW + 'px';
		resizes[j].style.height = parseInt(resizes[j].style.height) * scaleH + 'px';
		resizes[j].style.top = parseInt(resizes[j].style.top) * scaleH + 'px';
		resizes[j].style.left = parseInt(resizes[j].style.left) * scaleW + 'px';
		//confirm(j);
	}
	//resize 功能，在标签加上resize类名之后就以320*480为标准的屏幕上进行定位。

	var mySwiper = new Swiper('.swiper-container', {
		direction: 'vertical',
		grabCursor: true,
		//		parallax: true,
		loop: true, //loop和resize有冲突
		mousewheelControl: true, //鼠标滚动可以滑动
		onInit: function(swiper) { //Swiper2.x的初始化是onFirstInit，动画初始化
			swiperAnimateCache(swiper);
			swiperAnimate(swiper);
		},
		onSlideChangeEnd: function(swiper) {
			swiperAnimate(swiper);
		},
		onTransitionEnd: function(swiper) {
			swiperAnimate(swiper);
		},

		//以下为页面切换效果：立体切换翻转
		effect: 'coverflow', //slide的切换效果，默认为"slide"（位移切换），可设置为"fade"（淡入）"cube"（方块）"coverflow"（3d流）
		coverflow: {
			rotate: 20,
			stretch: 40,
			depth: 300,
			modifier: 2,
			slideShadows: true,
		},

		//回调函数，每次当Swiper开始过渡动画时持续执行。transtion获取到的是Swiper的speed值
		onSetTransition: function(swiper, speed) {
			for (var i = 0; i < swiper.slides.length; i++) {
				var slide = swiper.slides[i];
				slide.style.opacity = 1; //effect: 'coverflow'时候要设为1
				es = swiper.slides[i].style;
				es.webkitTransitionDuration = es.MsTransitionDuration = es.msTransitionDuration = es.MozTransitionDuration = es.OTransitionDuration = es.transitionDuration = speed + 'ms';
			}
		}

	})

	//初始化音乐
	var a = document.getElementById('bgMusicActionStop');
	var audio = globalCreateAudioPlayer();
	audio.init(a, true);
	$("#bgMusicBlock").click(function() {
		var played = audio.playOrPause();
		if (played) {
			$(".bgMusic").find("img").attr("src", "images/bgMusic.png");
			$(".bgMusic").find("img").addClass("bgMusic-img");
			$(".music-bg").show();
		} else {
			$(".bgMusic").find("img").attr("src", "images/bgMusic_close.png");
			$(".bgMusic").find("img").removeClass("bgMusic-img");
			$(".music-bg").hide();
		}
	});
	$("#bgMusicActionStop").attr("src", "other/music.mp3?v=" + new Date().getTime());
}
$.ajaxSetup({
	cache: false //设置成false将不会从浏览器缓存读取信息
});